<?php

use yii\db\Migration;

/**
 * Class m180803_031259_alter_comments_matching
 */
class m180803_031259_alter_comments_matching extends Migration
{
    /**
     * {@inheritdoc}
     */
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%comments_matching}}', 'calculation_id', $this->string(255)->defaultValue(0)->comment('计算公式id'));
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%comments_matching}}', 'calculation_id');
        }
    }
}
